<?php

namespace App\Http\Controllers;

use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;

class Controller extends BaseController
{

    use AuthorizesRequests, DispatchesJobs, ValidatesRequests;

    /**
     * 统一返回接口格式
     * @param array $data
     * @param string $msg
     * @param int $status
     * @param array $headers
     * @param int $options
     * @return \Illuminate\Http\JsonResponse
     */
    protected function json($data = [], $msg = 'success', $status = 200, array $headers = [], $options = 0)
    {
        $datas = [
            'code' => $status,
            'msg'  => $msg,
            'data' => $data,
        ];
        return response()->json($datas, $status, $headers, $options);
    }

}
